using System.Collections.Generic;
using UnityEngine;

public class BCWFlagControllerUI : MonoBehaviour
{
	[SerializeField]
	private FlagGridUI _myTeam;

	[SerializeField]
	private FlagGridUI _enemyTeam;

	[SerializeField]
	private FlagGridUI _neutralTeam;

	public Color _ourColor;

	public Color _enemyColor;

	private void Awake()
	{
	}

	private void OnDestroy()
	{
	}

	public void UpdateFlag(int neutralTeam, string[] nameNeutralTeam, int myTeam, string[] nameMyTeam, int enemyTeam, string[] nameEnemyTeam)
	{
		_myTeam.CountObject(myTeam, nameMyTeam);
		_enemyTeam.CountObject(enemyTeam, nameEnemyTeam);
	}

	public void UpdateGrid(string[] nameRedSprites, string[] nameBlueSprites)
	{
		if (TDMController.myTeam == PunTeams.Team.blue)
		{
			_myTeam.CreateSpritePixelmoon(nameBlueSprites);
			_enemyTeam.CreateSpritePixelmoon(nameRedSprites);
		}
		else if (TDMController.myTeam == PunTeams.Team.red)
		{
			_myTeam.CreateSpritePixelmoon(nameRedSprites);
			_enemyTeam.CreateSpritePixelmoon(nameBlueSprites);
		}
	}

	public void UpdateGrid(string[] nameRedSprites, string[] nameBlueSprites, string[] nameNeutralSprites, bool withTeamColor)
	{
		if (TDMController.myTeam == PunTeams.Team.blue)
		{
			List<string> list = new List<string>();
			if (nameBlueSprites != null)
			{
				foreach (string text in nameBlueSprites)
				{
					list.Add(text + ((!withTeamColor) ? string.Empty : " our"));
				}
				_myTeam.CreateSpritePixelmoon(list.ToArray());
			}
			else
			{
				_myTeam.CreateSpritePixelmoon(null);
			}
			List<string> list2 = new List<string>();
			if (nameRedSprites != null)
			{
				foreach (string text2 in nameRedSprites)
				{
					list2.Add(text2 + ((!withTeamColor) ? string.Empty : " enemy"));
				}
				_enemyTeam.CreateSpritePixelmoon(list2.ToArray());
			}
			else
			{
				_enemyTeam.CreateSpritePixelmoon(null);
			}
		}
		else if (TDMController.myTeam == PunTeams.Team.red)
		{
			List<string> list3 = new List<string>();
			if (nameRedSprites != null)
			{
				foreach (string text3 in nameRedSprites)
				{
					list3.Add(text3 + ((!withTeamColor) ? string.Empty : " our"));
				}
				_myTeam.CreateSpritePixelmoon(list3.ToArray());
			}
			else
			{
				_myTeam.CreateSpritePixelmoon(null);
			}
			List<string> list4 = new List<string>();
			if (nameBlueSprites != null)
			{
				foreach (string text4 in nameBlueSprites)
				{
					list4.Add(text4 + ((!withTeamColor) ? string.Empty : " enemy"));
				}
				_enemyTeam.CreateSpritePixelmoon(list4.ToArray());
			}
			else
			{
				_enemyTeam.CreateSpritePixelmoon(null);
			}
		}
		_neutralTeam.CreateSpritePixelmoon(nameNeutralSprites);
	}

	private void Update()
	{
		if (PVPManager.instance != null)
		{
			_myTeam.gameObject.SetActive(PVPManager.instance.gameIsStarted);
			_enemyTeam.gameObject.SetActive(PVPManager.instance.gameIsStarted);
		}
	}
}
